package com.selfdriving.activity;

import com.selfdriving.R;
import com.selfdriving.bean.Preference;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;

public class Welcome extends BaseActivity {

	@Override
	protected void onCreate(Bundle bundle) {
		super.onCreate(bundle);
		setContentView(R.layout.welcome);
		boolean flag = getBoolean(Preference.IS_FIRST_LOGIN, true);
		final boolean is_login = getBoolean(Preference.IS_LOGIN, true);
		if (!flag) {
			new Handler().postDelayed(new Runnable() {
				@Override
				public void run() {
					if (is_login) {
						Intent intent = new Intent(Welcome.this,
								HomePageActivity.class);
						startActivity(intent);
						overridePendingTransition(R.anim.push_left_in,
								R.anim.push_left_out);
						Welcome.this.finish();
					}
					else{
						Intent intent = new Intent(Welcome.this,
								RegisterActivity.class);
						startActivity(intent);
						overridePendingTransition(R.anim.push_left_in,
								R.anim.push_left_out);
						Welcome.this.finish();
					}

				}
			}, 2000);
		} else {
			new Handler().postDelayed(new Runnable() {
				@Override
				public void run() {
					Intent intent = new Intent(Welcome.this,
							GuideActivity.class);
					startActivity(intent);
					Welcome.this.finish();
				}
			}, 500);
			putBoolean(Preference.IS_FIRST_LOGIN, false, true);
		}
	}
}
